<template>
	<view class="page">
		<view class="iconBox">
			<view class="iconBox_left">
				<view class="iconBox_left_tou">
					
					<img :src="userInfo.avatar" alt="" style="width: 100%;height: 100%;">
				</view>
				<view class="iconBox_left_tps">
					<span>{{userInfo.name || ''}}</span>
					<span>{{userInfo.account || ''}}</span>
				</view>
			</view>
			<view class="iconBox_right" @click="imgShow(userInfo.erweima)">
				<img :src="userInfo.erweima" alt="" style="width: 100%;height: 100%;">
			</view>
		</view>
		<view class="fenGe"></view>
		<!-- <view class="items" @click="chanPing">
			<view class="items_title">
				产品问题
			</view>
			<u-icon name="arrow-right" color="#AFAFAF" size="20" style="margin-right: 20rpx;"></u-icon>
		</view> -->
		<view class="items" style="margin-top: 0rpx;" @click="weiMo">
			<view class="items_title">
				关于微摩汇
			</view>
			<u-icon name="arrow-right" color="#AFAFAF" size="20" style="margin-right: 20rpx;"></u-icon>
		</view>
		<view class="items" style="margin-top: 0rpx;" @click="chedaijisuanqi">
			<view class="items_title">
				车贷计算器
			</view>
			<u-icon name="arrow-right" color="#AFAFAF" size="20" style="margin-right: 20rpx;"></u-icon>
		</view>
		<view class="items" @click="wodedingdan">
			<view class="items_title">
				我的订单
			</view>
			<u-icon name="arrow-right" color="#AFAFAF" size="20" style="margin-right: 20rpx;"></u-icon>
		</view>
	</view>
</template>

<script>
	import {
		getCode
	} from '@/utils/weixin.util.js'
	export default {
		props:{
			userInfo:{
				type:Object,
				default:'',
			}
		},
		data() {
			return {
				avatar: '',
				phoneNumber: '',
				phoneCode: '',
				name:'',
				erweima:'',
			}
		},
		methods: {
			// 去登录
			toLogin() {
				uni.navigateTo({
					url: '/pages/ge_ren_zhong_xin/yin_hang_mine/login'
				})
			},
			// 获取code并登录
			qiTa() {
				getCode().then(code => {
					console.log(code, 'code')
					if (code) {
						this.getphonecode(code)

					} else {
						return
					}
				})
			},
			// 登录请求接口
			async getphonecode(code) {
				const res = await this.$post(`/auth/wxChat/register`, {
					code: code,
					phoneCode: this.phoneCode
				})
				console.log(res, 'res.data');
				if (res.status) {
					// uni.showToast({
					// 	title: '注册成功',
					// 	icon: 'success',
					// });
					getCode().then(code => {
						console.log(code, 'code')
						if (code) {
							this.login(code)
						} else {
							return
						}
					})

				}

			},
			// 登录请求接口
			async login(code) {
				const res = await this.$get(`/auth/wxChat/login`, {
					code: code
				})
				if (res.status) {
					console.log('客户端个人中');
					uni.setStorageSync('account', res.data.userInfo.account)
					uni.setStorageSync('token', res.data.token)
					uni.setStorageSync('clientUserId', res.data.userInfo.id)
					uni.setStorageSync('avatar', res.data.userInfo.avatar)
					this.phoneNumber = res.data.userInfo.account;
					this.name = res.data.userInfo.name;
					this.avatar = res.data.userInfo.avatar;
					this.erweima =11111
				}
			},
			// 预览图片
			imgShow(path) {
				// let path = this.$baseUrl + '@/static/ke_hu/tou_xiang.png'
				uni.previewImage({
					urls: [path]
				})
			},
			// 产品问题
			chanPing() {
				uni.navigateTo({
					url: '/pages/ke_hu_duan/wo_de_shen_qing/chanPingWenTi'
				})
			},
			weiMo() {
				uni.navigateTo({
					url: '/pages/ke_hu_duan/wo_de_shen_qing/wei_mo_hui'
				})
			},
			chedaijisuanqi() {
				uni.navigateTo({
					url: '/pages/che_dai_ji_suan_qi/che_dai_ji_suan_qi'
				})
			},
			wodedingdan(){
				uni.navigateTo({
					url: '/pages/xiao_shou_duan/wo_de_ding_dan'
				})
			}
		}
	}
</script>

<style>
	.page {
		overflow-y: auto;
		width: 100%;
		height: 100vh;
		background-color: #fff;
	}

	.iconBox {
		display: flex;
		align-items: center;
		justify-content: space-between;
		width: 636rpx;
		height: 104rpx;
		margin: 48rpx auto 45rpx;
	}

	.fenGe {
		width: 690rpx;
		height: 15rpx;
		background: #F4F4FA;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx auto 24rpx;
	}

	.items {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 0 31rpx;
		box-sizing: border-box;
		width: 690rpx;
		height: 97rpx;
		border-bottom: 2rpx solid #F4F4FA;
		/* background-color: aqua; */
		margin: 0 auto 0;
	}

	.items_left {
		font-size: 24rpx;
		font-family: 'PingFang SC-Regular, PingFang SC';
		font-weight: 400;
		color: #1A1824;

	}

	.iconBox_left,
	.iconBox_right {
		height: 100%;
	}

	.iconBox_left {
		display: flex;
		align-items: center;
		justify-content: flex-start;
	}

	.iconBox_left_tou {
		width: 104rpx;
		height: 104rpx;
		border-radius: 50%;
		overflow: hidden;
	}

	.iconBox_right {
		width: 104rpx;
		height: 104rpx;
	}

	.iconBox_left_tps {
		display: flex;
		flex-direction: column;
		align-items: flex-start;
		justify-content: center;
		margin-left: 29rpx;
	}

	.iconBox_left_tps span:first-child {
		height: 41rpx;
		font-size: 29rpx;
		font-family: 'PingFang SC-Bold, PingFang SC';
		font-weight: bold;
		color: #1D1C47;
		line-height: 41rpx;
	}

	.iconBox_left_tps span:last-child {
		height: 41rpx;
		font-size: 29rpx;
		font-family: 'PingFang SC-Bold, PingFang SC';
		font-weight: 500;
		color: #1D1C47;
		line-height: 40rpx;
		margin-top: 17rpx;
	}
</style>